home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / c-tools / vbcc / machines / amiga68k / libsrc / stdio / _fillbuf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-17  |  690 b   |  25 lines

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. /*  liest Daten in den Buffer   */
  5. int _fillbuf(FILE *f)
  6. {
  7.     _chkabort();
  8.     if(!f) return(EOF);
  9.     if((f->flags&(_READABLE|_WRITE|_EOF|_ERR))!=_READABLE) return(EOF);
  10.     f->flags|=_READ;
  11.     if(!f->bufsize){if(f->flags&_UNBUF) f->bufsize=1; else f->bufsize=BUFSIZ;}
  12.     if(!f->base)
  13.         if(!(f->base=(char *)malloc(f->bufsize+1)+1))
  14.             return(EOF);
  15.     f->pointer=f->base;
  16.     f->count=Read(f->filehandle,f->pointer,(long)f->bufsize);
  17.     if(--f->count<0){
  18.         if(f->count==-1) f->flags|=_EOF;
  19.          else            f->flags|=_ERR;
  20.         f->count=0;
  21.         return(EOF);
  22.     }
  23.     return((unsigned char) *f->pointer++);
  24. }
  25.